
<%@page import="Entity.Payment"%>
<%@page import="NamNH.UserPayDTO"%>
<%@page import="NamNH.NamNHSessionBeanLocal"%>
<%@page import="VietDQ.VietDQSessionBeanLocal"%>
<%@page import="javax.naming.InitialContext"%>
<%@page import="javax.naming.Context"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="Entity.Comment"%>
<%@page import="PhuocPH.EventCommentsDTO"%>
<%@page import="Entity.Event"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>

<%@page import="Entity.Account"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>National Level Paper Presentation</title>
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<link href="css/white/style.css" media="screen" title="shadow" rel="stylesheet" type="text/css" />
<link href="css/demo_table.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script>
    jQuery.noConflict();
</script>
<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#TableEvents').dataTable( {
					"aaSorting": [[ 4, "desc" ]]
				} );
			} );
</script>
</head>
<body>
    <!-----------------------------header--------------------------------------->
<div id="templatemo_header_wrapper">
    <jsp:include page="header.jsp" flush="true"/>

</div>
<!-------------------------------- end header ---------------------------------->

<!--------------------------------- menu ------------------------>
<div id="templatemo_menu_wrapper">
    <div id="templatemo_menu">

        <ul>
            <li><a href="index.jsp" >Home</a></li>
            <li><a href="VietDQServlet?action=UserGetAllEvents"class="current">Events</a></li>
<%
    if(session.getAttribute("User_Session")!=null){
        Account ac = (Account)session.getAttribute("User_Session");
%>
            <li><a href="PhuocPHServlet?action=UViewFB&User_Session=<%= ac.getUsername() %>">Feedback</a></li>
<%
            }
%>
            <li><a href="AboutUS.jsp">About Us</a></li>
            <li><a href="VietDQServlet?action=ViewFAQ">FAQ</a></li>
        </ul>

    </div>
</div>
<!---------------------------------end  menu ------------------------>

<!--------------------------------- Content ------------------------>
<div id="templatemo_content_wrapper">

	<div id="templatemo_sidebar">
            <div class="sidebar_box">
<%
                    if(session.getAttribute("User_Session")==null)
                    {

%>
            <h2>Login</h2>
            <form action="LoginServlet" method="post">
                <table>
                    <tr>
                    <td><label>Username: </label></td>
                    <td><input type="text" value="" name="txtUsername" id="input_field" /></td>
                    </tr>
                    <tr>
                    <td><label>Password: </label></td>
                    <td><input type="password" value="" name="txtPassword" id="input_field" /></td>
                    </tr>
                    <tr>
                     <td></td>
                        <td><input type="submit" name="action" value="Sign In" class="Button"/></td>
                    </tr>
                </table>
                 <%

                                   if(session.getAttribute("Invalid")!=null)
                                  {
                                %>
                                <label style="color: red"><%=session.getAttribute("Invalid").toString() %></label>
                                <%

                            }%>
                            <a href="Register.jsp">Sign Up</a>
                <br/>
               <a href="Forgot1.jsp">Forgot Password ?</a>
            </form>
 <%
            }else{
                       Account ac = (Account)session.getAttribute("User_Session");

                      DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
                      String date=df.format(ac.getDateJoin());
%>
                            <h2>Welcome</h2>
                            <form action="LoginServlet" method="post">
                    <table align="center">
                        <tr>
<%
        if(ac.getAvatar()==null)
            {
%>
                      <td colspan="2"><img class="avatar" src="images/avatar/avatar.jpg"/></td>
<%
        }else{

%>
                      <td colspan="2"><img class="avatar" src="images/avatar/<%= ac.getAvatar() %>"/></td>
<%
               }
%>
                      </tr>
                    <tr>
                   <%
                        if(ac.getGender().equals("Male"))
                            {
                %>
                    <td><label>
                      <div align="justify">Mr :</div>
                      </label></td>
                    <%
                            }else{
                    %>
                    <td><label>
                      <div align="justify">Ms :</div>
                      </label></td>
                    <%
                        }
                    %>
                    <td><label>
                      <div align="left"><%= ac.getFullname() %></div>
                    </label></td>
                    </tr>

                    <tr>
                     <td><label>
                       <div align="justify">Date Join :</div>
                      </label></td>
                        <td><label>
                          <div align="left"><%= date %></div>
                        </label></td>
                    </tr>
					  <tr>
                     <td><label>
                       <div align="justify">School :</div>
                       </label></td>
                        <td><label>
                          <div align="left"><%= ac.getSchool() %></div>
                        </label></td>
                    </tr>
					<tr>
                     <td><label>
                       <div align="justify">Address :</div>
                      </label></td>
                        <td><label>
                          <div align="left"><%= ac.getAddress() %></div>
                        </label></td>
                    </tr>
                    <tr>
                        <td colspan="2" align="left"><a href="NamNHServlet?action=USVIEWEV">Manage Event</a></td>
                    </tr>
                    <tr>
                        <td colspan="2" align="left"><a href="PhuocPHServlet?action=USVIEWCOM">Manage Comment</a></td>
                    </tr>
                    <tr>
                         <td> <a href="UpdateProfile.jsp">More Profile </a></td>
			 <td><input type="submit" name="action" value="Sign Out" class="Button"/></td>
		   </tr>
                </table>
                    </form>
<%
                }
%>
            <div class="cleaner"></div>

       </div><div class="sidebar_box_bottom"></div>

    	<div class="sidebar_box">
 <jsp:include flush="true" page="TopnewEvents.jsp"></jsp:include>
        </div><div class="sidebar_box_bottom"></div>

    </div>

    <div id="templatemo_content">

    	<div class="content_box1">

            <h2>DETAIL EVENT</h2><br/><br/>
            <table width="100%">
                <tbody>
<%
    Event evd = (Event)session.getAttribute("DETAILEVENT");


%>
                <tr>
<%
    if(evd.getEvImage()==null)
        {
%>
<td width="40%"><img class="ImageDetailEvent" src="images/Event/no_photo.jpg"/></td>
<%
        }
    else
        {
%>
<td width="40%"><img class="ImageDetailEvent" src="images/Event/<%= evd.getEvImage() %>"/></td>
<%
    }
%>
<td width="70%" align="left">
                        <h21>Event Name : </h21><%= evd.getEvName() %><br/>
                        <h21>Date Start : </h21><%= evd.getDateStart() %><br/>
                        <h21>Date End : </h21><%= evd.getDateEnd() %><br/>
                        <h21>Price : </h21>10$<br/><br/>
                        <%
                        if(evd.getWinner()!=null){
                            %>
                            <h21>Winner : </h21><span class="style1"><%=evd.getWinner() %></span>
                        <%
                        }else{
                        if(session.getAttribute("User_Session")!=null){
                        Context ctx = new InitialContext();
                        NamNHSessionBeanLocal NLocal = (NamNHSessionBeanLocal) ctx.lookup("NamNHSessionBeanLocalJNDI");
                         Account objAc = (Account)session.getAttribute("User_Session");
                        int validateEvent = 0;
                        int Id_compare = evd.getEvID();
                        request.getSession().setAttribute("EventDatontai", validateEvent);
                        UserPayDTO objUsPayDTO = NLocal.userViewHistoryPay(objAc.getUsername());
                        Payment[] listPay = objUsPayDTO.getListPayment();
                           for (int i= 0; i < listPay.length; i++) {
                            if(listPay[i].getEvent().getEvID()==Id_compare)
                            {
                                   validateEvent = 1;

                            }
                        }
                                Calendar cal = Calendar.getInstance();
                                DateFormat df2 = new SimpleDateFormat("dd/MM/yyyy");
                               cal.setTime(new Date());
                               
                          if(validateEvent ==1)
                              {
                         %>
                         <h2 style="color:  red;">You have register this Event !</h2>

                        <%}else if(!cal.getTime().after(df2.parse(evd.getDateEnd())))
                          {
                        %>
                        <a href="NamNHServlet?action=Pay&EvID=<%= evd.getEvID() %>"><img width="130" height="60" src="images/join-now.gif" /> </a>
                        <%
                            }else{
                        %>
                        <img width="200" height="80" src="images/Closed_Sorry.jpg"/>
                        <%
                                }   
                            }else{
                            %>
                        <h21>Please login to join event !!!</h21>
                        <%
                            }
                        }
                        %>
                </td>
                </tr>
                <tr>
                    <td colspan="2" align="left" valign="top"><h21>Description : </h21><textarea class="textDesEv" disabled><%= evd.getEvDescription() %></textarea></td>
                </tr>
                </tbody>
            </table><br/><br/>
        	<div class="cleaner"></div>
                <form action="PhuocPHServlet" method="post" id="Comment">
                    <table>
                    <tbody>
<%
    if(session.getAttribute("User_Session")!=null){
    Account ac = (Account)session.getAttribute("User_Session");
%>
                    <tr>
                                    <%
        if(ac.getAvatar()==null)
            {
%>
<td><img class="avatar1" src="images/avatar/avatar.jpg"/></td>
<%
        }else{

%>
                      <td><img class="avatar1" src="images/avatar/<%= ac.getAvatar() %>"/></td>
<%
               }
%>
                      <td><textarea name="txtComment" cols="60" rows="3" class="textCom"></textarea><br/>
                        <label for="txtComment" generated="true" class="error"></label></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td align="right">
                            <input type="hidden" name="txtEvid" value="<%= evd.getEvID() %>"/>
                            <input type="submit" name="action" value="Comment" class="Button"/> </td>
                    </tr>
<%
            }else
            {
%>
<tr>
    <td colspan="2"><h21>Please login to comment !!!</h21> </td>
</tr>
<%
            }
%>
                    </tbody>
                </table>
                    </form>
                    <script type="text/javascript">
    jQuery(document).ready(function($) {
           $("#Comment").validate({
             messages: {
                 txtComment: {
                     required: "Comment is required",
                     rangelength: "Comment must be from 10 to 150 characters"
                 }
            },
            rules: {
                txtComment: {
                    required: true,
                    rangelength: [10, 150]
                 }
            }
        });
    });
         $(".cancel").click(function() {
		validator.resetForm();
	});

 </script>
                <div class="cleaner"></div>
                <table><br/><br/>
<%
    EventCommentsDTO objDTO = (EventCommentsDTO)session.getAttribute("COMMENTEVENT");
    Comment[] listComment = objDTO.getListCom();
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
    for (int i = 0; i < listComment.length; i++) {
        String date = df.format(listComment[i].getDateCreate());
        if(listComment[i].getIDelete()==false)
            {
%>
                    <tbody>
                    <tr>
                                                            <%
        if(listComment[i].getAccount().getAvatar()==null)
            {
%>
<td valign="top"><img class="avatar1" src="images/avatar/avatar.jpg"/></td>
<%
        }else{

%>
<td valign="top"><img class="avatar1" src="images/avatar/<%= listComment[i].getAccount().getAvatar() %>"/></td>
<%
               }
%>
                        <td align="left"><textarea class="textCom" disabled><%= listComment[i].getComment() %></textarea> </td>
                    </tr>
                    <tr>
                        <td align="right" colspan="2">Comment by :<h21><%= listComment[i].getAccount().getUsername() %></h21>On :<h21><%= date %></h21></td>
                    </tr>
                    <tr>
                        <td colspan="2"><hr/></td>
                    </tr>
                    </tbody>
<%
                    }
                    }
%>
                </table>
                <div class="cleaner"></div>
        </div><div class="content_box_bottom1"></div>

    </div>

    <div class="cleaner"></div>

</div>

<!---------------------------------End Content ------------------------>

<div id="templatemo_footer_wrapper">

    <jsp:include page="footer.jsp" flush="true"/>

</div>
</body>
</html>
